package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.Goods;
import service.GoodsManager;
import service.impl.GoodsManagerFactory;

/**
 * Servlet implementation class EditServlet
 */
public class EditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private GoodsManager manager;    
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EditServlet() {
        super();
        manager = GoodsManagerFactory.getInstance();
    }
    

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String gid = request.getParameter("id");
		Goods goods = manager.loadGoods(gid);
		request.setAttribute("goods", goods);
		request.getRequestDispatcher("edit.jsp").forward(request, response);
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
